/**
  ******************************************************************************
  * @file    Libraries/Device/TS32F020D/ts32f020d_misc.h
  * @author  JUSHENG Application Team
  * @version V1.0.0
  * @date    02-19-2022
  * @brief   This file contains all the functions prototypes for the miscellaneous
  *          firmware library functions (add-on to CMSIS functions).
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2022 JUSHENG</center></h2>
  *
  *
  *
  ******************************************************************************
  */ 
  
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TS32F020D_HAL_MISC_H
#define __TS32F020D_HAL_MISC_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "typedef.h"
#include "ts32f020d.h"
#include "core_cm0.h"
     
/** @addtogroup TS32F020D_StdPeriph_Driver
  * @{
  */

/** @addtogroup MISC
  * @{
  */

/** @defgroup MISC_Exported_Constants
  * @{
  */

/** @defgroup System_Low_Power 
  * @{
  */

#define NVIC_LP_SEVONPEND                                   ((u8)0x10)
#define NVIC_LP_SLEEPDEEP                                   ((u8)0x04)
#define NVIC_LP_SLEEPONEXIT                                 ((u8)0x02)
#define IS_NVIC_LP(LP)                                      (((LP) == NVIC_LP_SEVONPEND) ||       \
                                                            ((LP) == NVIC_LP_SLEEPDEEP) ||        \
                                                            ((LP) == NVIC_LP_SLEEPONEXIT))
/**
  * @}
  */

/** @defgroup Preemption_Priority_Group 
  * @{
  */
#define IS_NVIC_PRIORITY(PRIORITY)                          ((PRIORITY) < 0x04)
/**
  * @}
  */

/** @defgroup SysTick_clock_source 
  * @{
  */

#define SysTick_CLKSource_HCLK_Div8                         ((u32)0xFFFFFFFB)
#define SysTick_CLKSource_HCLK                              ((u32)0x00000004)
#define IS_SYSTICK_CLK_SOURCE(SOURCE)                       (((SOURCE) == SysTick_CLKSource_HCLK) || \
                                                            ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
/**
  * @}
  */

/**
  * @}
  */

/** @defgroup MISC_Exported_Macros
  * @{
  */

/** 
  * @brief  NVIC Init Structure definition  
  */
typedef struct
{
    /*! Specifies the IRQ channel to be enabled or disabled.
     *  This parameter can be a value of @ref IRQn_Type 
     *  (For the complete STM32 Devices IRQ Channels list, 
     *  please refer to stm32f0xx.h file)
     */
    u8                                  NVIC_IRQChannel;

    /*! Specifies the priority level for the IRQ channel specified
     *  in NVIC_IRQChannel. This parameter can be a value
     *  between 0 and 3.
     */
    u8                                  NVIC_IRQChannelPriority;

    /*! Specifies whether the IRQ channel defined in NVIC_IRQChannel
     *  will be enabled or disabled. 
     *  This parameter can be set either to ENABLE or DISABLE
     */
    FunctionalState                     NVIC_IRQChannelCmd;
} NVIC_InitTypeDef;

/**
  * @}
  */

/** @defgroup MISC_Exported_Functions
  * @{
  */

void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
void NVIC_EnableIRQ(IRQn_Type IRQn);
void NVIC_DisableIRQ(IRQn_Type IRQn);
void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState);
void SysTick_CLKSourceConfig(u32 SysTick_CLKSource);
u32 SysTick_Config(uint32_t ticks);

#ifdef __cplusplus
}
#endif

#endif // __TS32F020D_HAL_MISC_H

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

/******************* (C) COPYRIGHT 2022 JUSHENG *****END OF FILE****/
